<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title>20-封装2个Number类型、2个string类型、2个boolean类型的2个数相加</title>
	</head>
	<body>
		<script type="text/javascript">
			/**
			 * @param {数值1} num1
			 * @param {数值2} num2
			 * @return {Number}
			 */
			function add(num1,num2){
				if(typeof num1=='number'&&typeof num2=='number'){
					return num1+num2;
				}else if(typeof num1=='string'&&typeof num2=='string'){
					return parseFloat(num1)+parseFloat(num2);
				}else if(typeof num1=='boolean'&&typeof num2=='boolean'){
					return num1+num2;
				}
			}
			
			//调用
			var x = add(1,9);//10
			var y = add('1','33');//34
			var z = add(true,false);//1
			
			console.log('number::'+x+'::string'+y+'::boolean::'+z);
			
			
			
		</script>
	</body>
</html>
